
Partial Class Presentation_SearchContacts
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim Sql As String
        Dim CountSql As String
        Dim Params(1) As GenParameter

        Page.Title = "Contact Search"

        Sql = "SELECT ContactMaster.ContactName, ContactMaster.ContactEmail, ContactMaster.Telephone, ContactMaster.Mobile, ClientMaster.ClientName, ContactMaster.Designation, ContactMaster.DecisionMaker" & _
            " FROM ((ClientMaster INNER JOIN CompanyAssignments ON ClientMaster.ClientID = CompanyAssignments.ClientID) INNER JOIN ExecutiveMaster ON CompanyAssignments.ExecutiveID = ExecutiveMaster.ExecutiveID) INNER JOIN ContactMaster ON ClientMaster.ClientID = ContactMaster.ClientID" & _
            " WHERE ContactMaster.ContactName LIKE CONCAT('%',?ClientPart,'%') AND ExecutiveMaster.ExecutiveUserName = ?ExecutiveName"

        Params(0) = New GenParameter("?ClientPart", txtContactPart.Text, Data.DbType.String)
        Params(1) = New GenParameter("?ExecutiveName", User.Identity.Name, Data.DbType.String)

        CountSql = "SELECT Count(*)" & _
            " FROM ((ClientMaster INNER JOIN CompanyAssignments ON ClientMaster.ClientID = CompanyAssignments.ClientID) INNER JOIN ExecutiveMaster ON CompanyAssignments.ExecutiveID = ExecutiveMaster.ExecutiveID) INNER JOIN ContactMaster ON ClientMaster.ClientID = ContactMaster.ClientID" & _
            " WHERE ContactMaster.ContactName LIKE CONCAT('%',?ClientPart,'%') AND ExecutiveMaster.ExecutiveUserName = ?ExecutiveName"

        ContactResults.Sql = Sql
        ContactResults.CountSql = CountSql
        ContactResults.Params = Params
        ContactResults.ShowButton = True

    End Sub

End Class
